package cn.locknow;

import android.app.Activity;
import android.app.admin.DeviceAdminReceiver;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class Main extends Activity {

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        DevicePolicyManager a = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName b = new ComponentName(this, DeviceAdminReceiver.class);
        if (a.isAdminActive(b))
            a.lockNow();
        else startActivity(new Intent("android.app.action.ADD_DEVICE_ADMIN")
                .putExtra("android.app.extra.DEVICE_ADMIN", b));

        finish();
    }
}
